package com.zyh.homework.test09;

import java.math.BigDecimal;

public class Test9 {
    public static void main(String[] args) {
        Handleable handle1=new Handleable() {
            @Override
            public String handleString(String num) {
                return new BigDecimal(num).divide(new BigDecimal("1"), 0, BigDecimal.ROUND_DOWN).toString();
            }
        };
        Handleable handle2=new Handleable() {
            @Override
            public String handleString(String num) {
                return new BigDecimal(num).divide(new BigDecimal("1"),4,BigDecimal.ROUND_HALF_UP).toString();
            }
        };
        String num = "23.23456789";
        System.out.println("原数字："+num);
        System.out.println("取整后："+handle1.handleString(num));
        System.out.println("原数字："+num);
        System.out.println("保留4位小数，四舍五入后："+handle2.handleString(num));
    }
}
